//
//  CSMACAInitiator.hpp
//  WiFiMACSim
//
//  Created by Christopher Kemsley on 4/1/12.
//  Copyright (c) 2012 iAppolopolis. All rights reserved.
//

#ifndef WiFiMACSim_CSMACANoVCSInitiator_hpp
#define WiFiMACSim_CSMACANoVCSInitiator_hpp

#include "Node.hpp"
#include "Message.hpp"
#include "Medium.hpp"
#include "Message.hpp"
#include "Statistics.hpp"

SimNamespaceBegin



class	CSMACANoVCSInitiator : public TransitionalStateMachineNode<CSMACANoVCSInitiator>
{
public:
	
	enum {
		kStateIdle				=	0 ,
		
		kStateSendingData		=	103 ,
		kStateWaitACKOrDifs		=	104 ,
		
		kStateVCSSawRTS			=	2 ,
		kStateVCSSawCTS			=	3
	} ;
	
	ID const	target ;
	
	UInteger	lambdaScalar ;
	Message*	message ;
	
	SlotTimer	timer ;
	
	static const UInteger	Infinity	=	((UInteger)(-1)) ;
	
	StateStat	statistics ;
	
	
	
	CSMACANoVCSInitiator ( ID const & name , ID const & inTarget , UInteger inLambdaScalar = 1 ) ;
	virtual ~CSMACANoVCSInitiator () ;
	
	
	
	
	
	
	void	run_idle			( Message * incoming , bool completed , bool isBusy ) ;
	
	void	run_vcs_saw			( Message * incoming , bool completed , bool isBusy ) ;
	
	
	void	run_sendingData		( Message * incoming , bool completed , bool isBusy ) ;
	void	run_waitACK_difs	( Message * incoming , bool completed , bool isBusy ) ;
	
	void	run_waitDifs		( Message * incoming , bool completed , bool isBusy ) ;
	
} ;




SimNamespaceEnd
#endif
